﻿

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
//using System.Windows.Media.Imaging;
//using System.Windows.Media;
using System.ComponentModel;
using System.Windows.Media;

namespace AutoEditUI
{
    internal class Version
    {
        public static string version = "V0.03";
    }



    public static class XmlSerializer
    {
        public static void SaveToXml(string filePath, object sourceObj, Type type, string xmlRootName)
        {
            if (!string.IsNullOrWhiteSpace(filePath) && sourceObj != null)
            {
                type = type != null ? type : sourceObj.GetType();
                using (StreamWriter writer = new StreamWriter(filePath))
                {
                    System.Xml.Serialization.XmlSerializer xmlSerializer = string.IsNullOrWhiteSpace(xmlRootName) ?
                        new System.Xml.Serialization.XmlSerializer(type) :
                        new System.Xml.Serialization.XmlSerializer(type, new XmlRootAttribute(xmlRootName));
                    xmlSerializer.Serialize(writer, sourceObj);
                }
            }
        }
        public static object LoadFromXml(string filePath, Type type)
        {
            object result = null;
            if (File.Exists(filePath))
            {
                using (StreamReader reader = new StreamReader(filePath))
                {
                    System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(type);
                    result = xmlSerializer.Deserialize(reader);
                }
            }
            return result;
        }
    }
    [XmlRootAttribute("UIModel", Namespace = "AutoEditUI", IsNullable = false)]
    public class UIModel
    {

        [XmlElementAttribute("W", IsNullable = false)]
        public double W
        {
            get;
            set;
        }
        [XmlElementAttribute("H", IsNullable = false)]
        public double H
        {
            get;
            set;
        }

        [XmlArrayAttribute("ItemIcons")]
        public List<ItemIcon> ItemIcons
        {
            get;
            set;
        }

        [XmlArrayAttribute("ItemCanvass")]
        public List<ItemCanvas> ItemCanvass
        {
            get;
            set;
        }
        [XmlArrayAttribute("ItemTexts")]
        public List<ItemText> ItemTexts
        {
            get;
            set;
        }
        [XmlArrayAttribute("ItemQRs")]
        public List<ItemQR> ItemQRs
        {
            get;
            set;
        }
        [XmlArrayAttribute("ItemBarcodes")]
        public List<ItemBarcode> ItemBarcodes
        {
            get;
            set;
        }
        [XmlArrayAttribute("ItemRects")]
        public List<ItemRect> ItemRects
        {
            get;
            set;
        }
        [XmlArrayAttribute("ItemCircles")]
        public List<ItemCircle> ItemCircles
        {
            get;
            set;
        }
        [XmlArrayAttribute("MKStackPanels")]
        public List<MKStackPanel> MKStackPanels 
        { get;  set; }
    }

    [XmlRootAttribute("ItemText")]
    public class ItemText : CanvasItem
    {
        [XmlElementAttribute("Color", IsNullable = false)]
        public string Color
        {
            get;
            set;
        }

        [XmlElementAttribute("Text", IsNullable = false)]
        public string Text
        {
            get;
            set;
        }


        [XmlElementAttribute("Font", IsNullable = false)]
        public string Font
        {
            get;
            set;
        }

        [XmlElementAttribute("FontSize", IsNullable = false)]
        public double FontSize
        {
            get;
            set;
        }



        [XmlElementAttribute("FontFamily", IsNullable = false)]
        public string FontFamily
        {
            get;
            set;
        }
        [XmlElementAttribute("FontWeight", IsNullable = false)]
        public int FontWeight { get;  set; }
      
        [XmlElementAttribute("TextBackBlack", IsNullable = true)]
        public Boolean? TextBackBlack { get;  set; }

        [XmlElementAttribute("TextMiddle", IsNullable = true)]
        public string TextMiddle { get; set; }


        public string Text_ { get; set; }
        
    }

    [XmlRootAttribute("ItemRect")]
    public class ItemRect : CanvasItem
    {
        [XmlElementAttribute("Color", IsNullable = false)]
        public string Color
        {
            get;
            set;
        }
    }


    [XmlRootAttribute("ItemIcon")]
    public class ItemIcon : CanvasItem
    {
       

        [XmlElementAttribute("ItemBin", IsNullable = false)]
        public string ItemBin { get;  set; }

        //
        //public string Background { get; set; }
    }

    [XmlRootAttribute("ItemCanvas")]
    public class ItemCanvas : CanvasItem
    {


        [XmlElementAttribute("ItemBin", IsNullable = true)]
        public string ItemBin { get; set; }
        //public string ItemBin
        //{
        //    get { return System.Security.SecurityElement.Escape(ItemBin); }
        //    set { ItemBin = value; }
        //}

        //
        //public string Background { get; set; }
    }

    [XmlRootAttribute("ItemQR")]
    public class ItemQR : CanvasItem
    {
       
        [XmlElementAttribute("ItemValue", IsNullable = false)]
        public string ItemValue
        {
            get;
            set;
        }

    }

    [XmlRootAttribute("ItemBarcode")]
    public class ItemBarcode : CanvasItem
    {
       
        [XmlElementAttribute("ItemValue", IsNullable = false)]
        public string ItemValue
        {
            get;
            set;
        }

    }

    [XmlRootAttribute("MKStackPanel")]
    public class MKStackPanel : CanvasItem
    {

        [XmlElementAttribute("b_H", IsNullable = false)]
        public Boolean B_H
        {
            get;
            set;
        }

    }

    [XmlRootAttribute("CanvasItem")]
    public class CanvasItem: UIItem
    {
        
    }
    [XmlRootAttribute("ItemCircle")]
    public class ItemCircle : UIItem
    {
        [XmlElementAttribute("Radius", IsNullable = false)]
        public string Radius
        {
            get;
            set;
        }
        [XmlElementAttribute("Lineheight", IsNullable = false)]
        public string Lineheight
        {
            get;
            set;
        }
    }
    [XmlRootAttribute("UIItem")]
    public class UIItem
    {
        public Boolean b_show { get; set; }

        [XmlElementAttribute("W", IsNullable = false)]
        public double W
        {
            get;
            set;
        }
        [XmlElementAttribute("H", IsNullable = false)]
        public double H
        {
            get;
            set;
        }

        [XmlElementAttribute("ItemType", IsNullable = true)]
        public string ItemType
        {
            get;
            set;
        }
        [XmlElementAttribute("ItemName", IsNullable = false)]
        public string ItemName
        {
            get;
            set;
        }

        [XmlElementAttribute("X", IsNullable = false)]
        public double X
        {
            get;
            set;
        }

        [XmlElementAttribute("Y", IsNullable = false)]
        public double Y
        {
            get;
            set;
        }

        [XmlElementAttribute("UpItem", IsNullable = true)]
        public string UpItemTag
        {
            get;
            set;
        }

        [XmlElementAttribute("LeftItem", IsNullable = true)]
        public string LeftItemTag
        {
            get;
            set;
        }

        [XmlElementAttribute("UpValue", IsNullable = false)]
        public double UpValue
        {
            get;
            set;
        }

        [XmlElementAttribute("LeftValue", IsNullable = false)]
        public double LeftValue
        {
            get;
            set;
        }


        [XmlElementAttribute("Tag", IsNullable = true)]
        public string Tag
        {
            get;
            set;
        }

        [XmlElementAttribute("MESBindStr", IsNullable = true)]
        public string MESBindStr
        {
            get;
            set;
        }

        [XmlElementAttribute("Background", IsNullable = false)]
        public string Background { get;  set; }

        [XmlElementAttribute("ParentTag", IsNullable = false)]
        public string ParentTag { get;  set; }

       
    }




   


    [XmlRootAttribute("ProjectInfo")]
    public class ProjectInfo
    {
        [XmlElementAttribute("DisplayName", IsNullable = false)]
        public string DisplayName { get; set; }
        [XmlElementAttribute("BU", IsNullable = false)]
        public string BU { get; set; }
        [XmlElementAttribute("Status", IsNullable = false)]
        public string Status { get; set; }
        [XmlElementAttribute("Creater", IsNullable = false)]
        public string Creater { get; set; }
        [XmlElementAttribute("UUID", IsNullable = false)]
        public string UUID { get; set; }
        [XmlElementAttribute("ProjectName", IsNullable = false)]
        public string ProjectName { get; set; }
        [XmlElementAttribute("ModelName", IsNullable = false)]
        public string ModelName { get; set; }
        [XmlArrayAttribute("MarketingNameClassList")]
        
        [XmlElementAttribute("IndiaModelNameDis", IsNullable = false)]
        public string IndiaModelNameDis { get; set; }
        [XmlElementAttribute("IndiaModelNameUMA", IsNullable = false)]
        public string IndiaModelNameUMA { get; set; }
        [XmlElementAttribute("ModelNamePRC", IsNullable = false)]
        public string ModelNamePRC { get; set; }
        [XmlElementAttribute("ModelNameUSCA", IsNullable = false)]
        public string ModelNameUSCA { get; set; }
        [XmlElementAttribute("dl", IsNullable = false)]
        public string DL { get; set; }
        [XmlElementAttribute("dy", IsNullable = false)]
        public string DY { get; set; }
        [XmlElementAttribute("MTCodeWW", IsNullable = false)]
        public string MTCode { get; set; }
        [XmlElementAttribute("MTCodeUSCA", IsNullable = false)]
        public string MTCodeUSCA { get; set; }
        [XmlElementAttribute("MTCodePRC", IsNullable = false)]
        public string MTCodePRC { get; set; }
        [XmlElementAttribute("MTCodeIndiaUMA", IsNullable = false)]
        public string MTCodeIndiaUMA { get; set; }
        [XmlElementAttribute("MTCodeIndiaDis", IsNullable = false)]
        public string MTCodeIndiaDis { get; set; }
        [XmlElementAttribute("LabelSize1", IsNullable = false)]
        public string LabelSize1 { get; set; }
        [XmlElementAttribute("LabelSize2", IsNullable = false)]
        public string LabelSize2 { get; set; }
        [XmlElementAttribute("Country", IsNullable = false)]
        public string Country { get; set; }
        [XmlElementAttribute("FactoryProjectName", IsNullable = false)]
        public string FactoryProjectName { get; set; }
        [XmlElementAttribute("DCInterface", IsNullable = false)]
        public string DCInterface { get; set; }
        [XmlElementAttribute("RSInterface", IsNullable = false)]
        public string RSInterface { get; set; }
        [XmlElementAttribute("FactoryID", IsNullable = false)]
        public string FactoryID { get; set; }
        //[XmlElementAttribute("Belabel", IsNullable = false)]
        //public string Belabel { get; set; }
    }



}
